package com.ysm.smfu.utils;

import android.text.TextUtils;

import com.ysm.smfu.contans.SpKey;

import java.sql.Timestamp;
import java.util.Map;
import java.util.TreeMap;

/**
 * Created by Administrator on 2016/10/13.
 */
public class SignUtil {

    /**
     * 注册页获取验证码签名
     *
     * @return
     */
    public static String sign(String nonce, long l, String phoneNumber, String types) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", getTimeStamp(l));
        map.put("userName", phoneNumber);
        map.put("types", types);

        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 设置登录密码签名
     *
     * @param nonce
     * @param phoneNumber
     * @return nonce, SignUtil.getTimeStamp(l), phoneNumber,psd,codeString,"register"
     */
    public static String sign(String nonce, String timestamp, String phoneNumber, String psd) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("pwd", psd);
        map.put("phone", phoneNumber);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 登录签名
     *
     * @param l
     * @param nonce
     * @param phoneNumber
     * @return
     */
    public static String sign(String nonce, String psd, String phoneNumber, long l) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("pwd", psd);
        map.put("username", phoneNumber);
        map.put("timestamp", getTimeStamp(l));
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 登录签名
     *
     * @param timestamp
     * @param nonce
     * @param phoneNumber
     * @return
     */
    public static String signForLogin(String nonce, String psd, String phoneNumber, String timestamp) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("pwd", psd);
        map.put("username", phoneNumber);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * singLogin签名
     *
     * @param username
     * @param pwd
     * @param timestamp
     * @param nonce
     * @return
     */
    public static String signLogin(String username, String pwd, String timestamp, String nonce) {
        Map<String, String> map = new TreeMap<>();
        map.put("userName", username);
        map.put("pwd", pwd);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 修改登录密码签名/获取用户信息
     */
    public static String sign(String id, String nonce, long l) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", id);
        map.put("nonce", nonce);
        map.put("timestamp", getTimeStamp(l));
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 首页获取商家签名
     *
     * @return
     */
    public static String signForGetGoodsInfo(String nonce, String timestamp, String lng, String lat, String page, String showNumber, String cityId, String curCityId) {
        Map<String, String> map = new TreeMap<>();
        if (!TextUtils.isEmpty(nonce))
            map.put("nonce", nonce);
        if (!TextUtils.isEmpty(timestamp))
            map.put("timestamp", timestamp);
        if (!TextUtils.isEmpty(lng) && !TextUtils.isEmpty(lat) && !TextUtils.isEmpty(curCityId)) {
            map.put("lng", lng);
            map.put("lat", lat);
            map.put("curCityId", curCityId);
        }
        if (!TextUtils.isEmpty(page))
            map.put("page", page);
        if (!TextUtils.isEmpty(showNumber))
            map.put("showNumber", showNumber);
        if (!TextUtils.isEmpty(cityId))
            map.put("cityId", cityId);
        else if (!TextUtils.isEmpty(curCityId))
            map.put("cityId", curCityId);
        else if (!TextUtils.isEmpty(curCityId)) {
            map.put("cityId", curCityId);
        }

        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 获取时间戳
     *
     * @return
     */
    public static String getTimeStamp(long l) {
        Timestamp timeStamp = new Timestamp(l);
        return timeStamp.toString();
    }

    /**
     * 修改密码签名
     *
     * @param code
     * @param sPsd
     * @param nonce
     * @param phone
     * @param timeStamp
     * @return
     */
    public static String sign(String code, String fPsd, String sPsd, String nonce, String phone, String timeStamp, String password) {
        Map<String, String> map = new TreeMap<>();
        map.put("code", code);
        map.put("phone", phone);
        map.put("pwd,", fPsd);
        map.put("confirmPwd", sPsd);
        map.put("nonce", nonce);
        map.put("type", password);
        map.put("timestamp", timeStamp);

        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 对验证码进行验证签名
     *
     * @param code
     * @param nonce
     * @param phoneNumber
     * @param timeStamp
     * @return phone:手机号
     * code:验证码
     * type:验证码类型
     */
    public static String signForChechCode(String code, String nonce, String phoneNumber, String timeStamp, String type, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("code", code);
        map.put("nonce", nonce);
        map.put("type", type);
        map.put("phone", phoneNumber);
        map.put("timestamp", timeStamp);
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 获取验证码
     *
     * @param nonce
     * @param timeStamp
     * @param phoneNum
     * @param type
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForGetYzCode(String nonce, String timeStamp, String phoneNum, String type, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("type", type);
        map.put("userName", phoneNum);
        map.put("timestamp", timeStamp);
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 检测验证码
     */
    public static String signForCheckYzCode(String nonce, String timeStamp, String num, String type, String code, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("phone", num);
        map.put("type", type);
        map.put("code", code);
        map.put("timestamp", timeStamp);
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 添加或忽略好友签名
     *
     * @param userId
     * @param id
     * @param s
     * @param signLogin
     * @param loginId
     * @param nonce
     * @param timeStamp
     * @return
     */
    public static String signForAddFriend(String userId, String id, String s, String signLogin, String loginId, String nonce, String timeStamp) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", userId);
        map.put("firendId", id);
        map.put("nonce", nonce);
        map.put("state", s);
        map.put("timestamp", timeStamp);
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 删除好友签名
     *
     * @param userId
     * @param id
     * @param nonce
     * @param timeStamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForDel(String userId, String id, String nonce, String timeStamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", userId);
        map.put("firendId", id);
        map.put("nonce", nonce);
        map.put("timestamp", timeStamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 获取联系人
     *
     * @param userId
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForContact(String userId, String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", userId);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 主动添加别人
     *
     * @param myID
     * @param userId
     * @param nonce
     * @param l
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForAddOthers(String myID, String userId, String nonce, long l, String signLogin, String loginId) {

        Map<String, String> map = new TreeMap<>();
        map.put("id", myID);
        map.put("firendId", userId);
        map.put("nonce", nonce);
        map.put("timestamp", getTimeStamp(l));
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 搜索好友签名
     *
     * @param userNam
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForZhSearch(String userNam, String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("phone", userNam);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 获取类型
     *
     * @param nonce
     * @param timeStamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForGetType(String nonce, String timeStamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timeStamp);
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 分类搜索
     */
    public static String signForSearch(String lng, String lat, String page, String showNumber, String nonce,
                                       String timeStamp, String cityId, String curCityId, String keyWord) {
        Map<String, String> map = new TreeMap<>();
        if (!TextUtils.isEmpty(lng))
            map.put("lng", lng);
        if (!TextUtils.isEmpty(lat))
            map.put("lat", lat);
        map.put("page", page);
        map.put("showNumber", showNumber);
        map.put("nonce", nonce);
        map.put("timestamp", timeStamp);
        if (!TextUtils.isEmpty(cityId))
            map.put("cityId", cityId);
        else if (!TextUtils.isEmpty(curCityId))
            map.put("cityId", curCityId);
        if (!TextUtils.isEmpty(curCityId))
            map.put("curCityId", curCityId);
        map.put("search", keyWord);
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 检测支付状态
     *
     * @param userId
     * @param nonce
     * @param timeStamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForCheckZFPayState(String userId, String nonce, String timeStamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", userId);
        map.put("nonce", nonce);
        map.put("timestamp", timeStamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 修改支付密码
     *
     * @param userId
     * @param psd
     * @param nonce
     * @param timeStamp
     * @param signLogin
     * @param loginId
     * @param password
     * @return
     */
    public static String signForXiuGaiZhiFuPsd(String userId, String psd, String nonce, String timeStamp, String signLogin, String loginId, String password, String code, String phone) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", userId);
        map.put("nonce", nonce);
        map.put("timestamp", timeStamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("payPwd", psd);
        if (!TextUtils.isEmpty(password))
            map.put("type", password);
        if (!TextUtils.isEmpty(code))
            map.put("code", code);
        if (!TextUtils.isEmpty(phone)) {
            map.put("phone", phone);
        }
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 申请商户
     *
     * @param userId
     * @param select_id
     * @param shanghuName
     * @param num
     * @param profile
     * @param serveceNum
     * @param provinceCode
     * @param nonce
     * @param timeStamp
     * @param cityCode
     * @param countryCode
     * @param detailAddr
     * @param isAbout
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForShangHu(String userId, String select_id, String shanghuName, String num,
                                        String profile, String serveceNum, String provinceCode, String nonce, String timeStamp,
                                        String cityCode, String countryCode, String lng, String lat, String detailAddr, String isAbout,
                                        String signLogin, String loginId) {

        Map<String, String> map = new TreeMap<>();
        map.put("userId", userId);
        map.put("classId", select_id);
        map.put("name", shanghuName);
        map.put("phone", num);
        map.put("discount", profile);
        map.put("telephone", serveceNum);
        map.put("provinceId", provinceCode);
        map.put("cityId", cityCode);
        if (!TextUtils.equals(countryCode, "820210") && !TextUtils.equals(countryCode, "820110"))
            map.put("countryId", countryCode);
        map.put("lng", lng);
        map.put("lat", lat);
        if (!TextUtils.isEmpty(detailAddr))
            map.put("address", detailAddr);
        map.put("isAbout", isAbout);
        map.put("timestamp", timeStamp);
        map.put("nonce", nonce);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
//        map.put("jointPhone", jointPhone);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 根据金额设置订单
     *
     * @param remark
     * @param totalPrice
     * @param bussinessId
     * @param userId
     * @param loginId
     * @param signLogin
     * @param nonce
     * @param timestamp
     * @return
     */
    public static String signForCreateDingdan_Money(String totalPrice, String bussinessId,
                                                    String userId, String loginId,
                                                    String signLogin, String nonce, String timestamp, String remark) {
        Map<String, String> map = new TreeMap<>();
        map.put("totalPrice", totalPrice);
        map.put("businessId", bussinessId);
        map.put("userId", userId);
        map.put("nonce", nonce);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("timestamp", timestamp);
        if (!TextUtils.isEmpty(remark))
            map.put("remark", remark);
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 根据金额设置订单
     *
     * @param jifen
     * @param businessId
     * @param userId
     * @param signLogin
     * @param loginId
     * @param nonce      @return
     */
    public static String signForCreateDingdan_JiFen(String jifen, String businessId, String userId,
                                                    String signLogin, String loginId, String nonce, String timestamp, String money, String remark) {
        Map<String, String> map = new TreeMap<>();
        map.put("totalPointsNum", jifen);
        map.put("businessId", businessId);
        map.put("userId", userId);
        map.put("nonce", nonce);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("timestamp", timestamp);
        if (!TextUtils.isEmpty(money))
            map.put("totalPrice", money);
        if (!TextUtils.isEmpty(remark))
            map.put("remark", remark);
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 付款时，通过businessId获取商家信息
     *
     * @param businessId
     * @param timestamp
     */
    public static String signForShanghuInfoByBussinId(String businessId, String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("businessId", businessId);
        map.put("nonce", nonce);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 付款时，通过PayCode获取支付状态
     */
    public static String signForPayStateByPayCode(String dingdanCode, String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("payCode", dingdanCode);
        map.put("nonce", nonce);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 支付金额或兑换券
     *
     * @param dingdanCode
     * @param businessId
     * @param money
     * @param userId
     * @param psd
     * @param nonce
     * @param signLogin
     * @param loginId
     * @param android
     * @param level
     * @return
     */
    public static String signForPay(String dingdanCode, String businessId, String money, String userId,
                                    String psd, String nonce, String timestamp, String signLogin, String loginId, String android, String level) {
        Map<String, String> map = new TreeMap<>();
        if (!TextUtils.isEmpty(dingdanCode))
            map.put("payCode", dingdanCode);
        if (!TextUtils.isEmpty(businessId))
            map.put("businessId", businessId);
        if (!TextUtils.isEmpty(money))
            map.put("money", money);
        map.put("id", userId);
        map.put("payPwd", psd);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("tag", android);
        map.put("userLevel", level);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 获取用户信息
     *
     * @param id
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForGetUserInfo(String id, String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", id);
        map.put("nonce", nonce);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 获取商家详情
     *
     * @param businessId
     * @param nonce
     * @param timestamp
     * @return
     */
    public static String signForGetBusinessInfo(String businessId, String nonce, String timestamp) {
        Map<String, String> map = new TreeMap<>();
        map.put("businessId", businessId);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 在线商城
     *
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     */
    public static String signForOnline(String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        if (!TextUtils.isEmpty(loginId)) {
            map.put("signLogin", signLogin);
            map.put("loginId", loginId);
        }
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 设置系统消息为已读
     *
     * @param userId
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForSetSys(String userId, String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", userId);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 检测商户状态
     *
     * @param userId
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForChechShangState(String userId, String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("userId", userId);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 修改登录密码
     *
     * @param code
     * @param fPsd
     * @param sPsd
     * @param nonce
     * @param phone
     * @param timeStamp
     * @param password
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForModifyLoginPsd(String code, String fPsd, String sPsd, String nonce, String phone, String timeStamp, String password, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("code", code);
        map.put("pwd", fPsd);
        map.put("confirmPwd", sPsd);
        map.put("nonce", nonce);
        map.put("phone", phone);
        map.put("type", password);
        map.put("timestamp", timeStamp);
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 收款明细
     *
     * @param businessId
     * @param nonce
     * @param timeStamp
     * @param signLogin
     * @param loginId
     * @param currPage
     * @param number     @return
     */
    public static String signForShouKuanMingXI(String businessId, String nonce, String timeStamp, String signLogin, String loginId, int currPage, String number) {
        Map<String, String> map = new TreeMap<>();
        map.put("businessId", businessId);
        map.put("nonce", nonce);
        map.put("timestamp", timeStamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("page", String.valueOf(currPage));
        map.put("showNumber", number);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 注册
     *
     * @param nonce
     * @param timeStamp
     * @param phoneNumber
     * @param psd
     * @param codeString
     * @param register
     * @return
     */
    public static String signForRegister(String nonce, String timeStamp, String phoneNumber, String psd, String codeString, String register) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("phone", phoneNumber);
        map.put("timestamp", timeStamp);
        map.put("pwd", psd);
        map.put("code", codeString);
        map.put("type", register);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 更新用户信息
     *
     * @param id
     * @param nc
     * @param sex1
     * @param dq
     * @param sr
     * @param nonce
     * @param timeStamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForUpadateInfo(String id, String nc, String sex1, String dq, String sr, String nonce, String timeStamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", id);
        map.put("nonce", nonce);
        map.put("timestamp", timeStamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("petName", nc);
        map.put("sex", sex1);
        map.put("address", dq);
        map.put("birthday", sr);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 获取支付宝支付通知RUL签名
     *
     * @param nonce
     * @param timestamp
     * @param level
     * @param userId
     * @param dingdanCode
     * @param loginId
     * @param signLogin   @return
     * @param android
     */
    public static String signForAlipay(String nonce, String timestamp, String level, String userId, String dingdanCode, String loginId, String signLogin, String android) {
        Map<String, String> map = new TreeMap<>();
        map.put("userLevel", level);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("id", userId);
        map.put("payCode", dingdanCode);
        map.put("tag", android);
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 预支付获取通知URL
     *
     * @param nonce
     * @param timestamp
     * @param userId
     * @param businessId
     * @param money
     * @param loginId
     * @param signLogin
     * @param android
     * @return
     */
    public static String signForAlipayNoCode(String nonce, String timestamp, String userId,
                                             String businessId, String money, String jifen,
                                             String loginId, String signLogin, String android) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);

        map.put("id", userId);
        map.put("businessId", businessId);
        map.put("money", money);
        map.put("points", jifen);
        map.put("tag", android);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    public static String signForCategory(String lon, String lat, String page, String showNumber, String nonce, String timeStamp, String cityId, String currCityId, String typeId) {
        Map<String, String> map = new TreeMap<>();
        if (!TextUtils.isEmpty(lon))
            map.put("lng", lon);
        if (!TextUtils.isEmpty(lat))
            map.put("lat", lat);
        map.put("page", page);
        map.put("showNumber", showNumber);
        map.put("nonce", nonce);
        map.put("timestamp", timeStamp);
        if (!TextUtils.isEmpty(cityId))
            map.put("cityId", cityId);
        else if (!TextUtils.isEmpty(currCityId))
            map.put("cityId", currCityId);
        if (!TextUtils.isEmpty(currCityId))
            map.put("curCityId", currCityId);
        map.put("classId", typeId);
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 修改支付密码
     *
     * @param userId
     * @param psd
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForPayPsd(String userId, String psd, String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", userId);
        map.put("payPwd", psd);
        map.put("nonce", nonce);
        map.put("loginId", loginId);
        map.put("signLogin", signLogin);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 清除订单
     *
     * @param dingdanCode
     * @param signLogin
     * @param loginId
     * @param timeStamp
     * @param nonce
     * @return
     */
    public static String signForClearQr(String dingdanCode, String signLogin, String loginId, String timeStamp, String nonce) {
        Map<String, String> map = new TreeMap<>();
        map.put("payCode", dingdanCode);
        map.put("nonce", nonce);
        map.put("loginId", loginId);
        map.put("signLogin", signLogin);
        map.put("timestamp", timeStamp);
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 邀请好友
     *
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @param codePre
     * @param codeSuf
     * @return
     */
    public static String signForInvitF(String id, String nonce, String timestamp, String signLogin, String loginId, String codePre, String codeSuf) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", id);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("codePre", codePre);
        map.put("codeSuf", codeSuf);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 账单详情
     *
     * @param id
     * @param nonce
     * @param timestamp
     * @return
     */
    public static String signForZhangDan(String id, String page, String showNumber, String nonce, String timestamp) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", id);
        map.put("page", page);
        map.put("showNumber", showNumber);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }


    public static String sign(String nonce, String timestamp) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 获取历史版本
     *
     * @param page
     * @param showNumber
     * @param nonce
     * @param timestamp
     * @return
     */
    public static String signForHistoryVersion(String page, String showNumber, String nonce, String timestamp) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("page", page);
        map.put("showNumber", showNumber);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 付款签名
     *
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @param s
     * @param stateOrder
     * @return
     */
    public static String signForFukuan(String nonce, String timestamp, String signLogin, String loginId, String s, String stateOrder) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        map.put("state", s);
        map.put("type", stateOrder);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 检测新版本
     *
     * @param nonce
     * @param timestamp
     * @param s
     * @param s1
     * @param android
     * @return
     */
    public static String signForVersion(String nonce, String timestamp, String s, String s1, String android) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("page", s);
        map.put("showNumber", s1);
        map.put("appType", android);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 清除积分订单
     *
     * @param dingdanCode
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId     @return
     */
    public static String signForClearJiFenQr(String dingdanCode, String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("payCode", dingdanCode);
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 微信扫码支付
     *
     * @param userId
     * @param payCode
     * @param userLevel
     * @param android
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @return
     */
    public static String signForWxPay(String userId, String payCode, String userLevel, String android, String nonce, String timestamp, String signLogin, String loginId) {
        Map<String, String> map = new TreeMap<>();
        map.put("id", userId);
        map.put("payCode", payCode);
        map.put("userLevel", userLevel);
        map.put("tag", android);
        map.put("timestamp", timestamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);
        map.put("nonce", nonce);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 预支付调用微信
     *
     * @param nonce
     * @param timestamp
     * @param userId
     * @param businessId
     * @param money
     * @param loginId
     * @param signLogin
     * @param android
     * @param jifen
     * @return
     */
    public static String signForWXpayNoCode(String nonce, String timestamp, String userId, String businessId,
                                            String money, String loginId, String signLogin, String android, String jifen) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);

        map.put("id", userId);
        map.put("businessId", businessId);
        map.put("money", money);
        map.put("points", jifen);
        map.put("tag", android);
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 微信支付成功签名
     *
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @param code
     * @return
     */
    public static String signForOnlineWX(String nonce, String timestamp, String signLogin, String loginId, String code) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        if (!TextUtils.isEmpty(signLogin))
            map.put("signLogin", signLogin);
        if (!TextUtils.isEmpty(loginId))
            map.put("loginId", loginId);
        map.put("code", code);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 余额支付签名
     *
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @param userId
     * @param psd
     * @param money
     * @param jifen
     * @param tag
     * @param level
     * @param businessId
     * @return
     */
    public static String signForPayMonty(String nonce, String timestamp, String signLogin, String loginId, String userId, String psd, String money, String jifen, String businessId, String tag, String level) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("signLogin", signLogin);
        map.put("loginId", loginId);

        map.put("id", userId);
        map.put("payPwd", psd);
        map.put("businessId", businessId);
        map.put("tag", tag);
        map.put("userLevel", level);
        map.put("money", money);
        map.put("points", jifen);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 在用户未登录状态下，通过UserId获取用户信息
     *
     * @param userId
     * @param nonce
     * @param timestamp
     * @return
     */
    public static String signForGetUserInfoByUserId(String userId, String nonce, String timestamp) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("id", userId);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 广告数据签名
     *
     * @param nonce
     * @param timestamp
     * @return
     */
    public static String signForAd(String nonce, String timestamp) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 广告链接签名
     *
     * @param nonce
     * @param timestamp
     * @param signLogin
     * @param loginId
     * @param adId      广告id
     * @return
     */
    public static String signForAdLink(String nonce, String timestamp, String signLogin, String loginId, String adId) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("id", adId);
        if (!TextUtils.isEmpty(loginId)) {
            map.put("signLogin", signLogin);
            map.put("loginId", loginId);
        }
        return Md5Utils.createSign(map, SpKey.KEY);

    }

    /**
     * 获取首页产品签名
     *
     * @param nonce
     * @param timestamp
     * @param page
     * @param showNumber
     * @return
     */
    public static String signForHomeProduct(String nonce, String timestamp, String page, String showNumber) {
        Map<String, String> map = new TreeMap<>();
        if (!TextUtils.isEmpty(nonce))
            map.put("nonce", nonce);
        if (!TextUtils.isEmpty(timestamp))
            map.put("timestamp", timestamp);
        if (!TextUtils.isEmpty(page))
            map.put("page", page);
        if (!TextUtils.isEmpty(showNumber))
            map.put("showNumber", showNumber);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 获取首页产品跳转链接
     *
     * @param nonce
     * @param timestamp
     * @param id
     * @return
     */
    public static String signForProductUrl(String nonce, String timestamp, String id) {
        Map<String, String> map = new TreeMap<>();
        if (!TextUtils.isEmpty(nonce))
            map.put("nonce", nonce);
        if (!TextUtils.isEmpty(timestamp))
            map.put("timestamp", timestamp);
        if (!TextUtils.isEmpty(id))
            map.put("goodsId", id);
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 首页跳转到产品详情
     * @param nonce
     * @param timestamp
     * @param loginId
     * @param signLogin
     * @param goodsId
     * @return
     */
    public static String signForGoods(String nonce, String timestamp, String loginId, String signLogin, String goodsId) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("goodsId", goodsId);
        if (!TextUtils.isEmpty(loginId)) {
            map.put("signLogin", signLogin);
            map.put("loginId", loginId);
        }
        return Md5Utils.createSign(map, SpKey.KEY);
    }

    /**
     * 获取是否强推配置
     * @param nonce
     * @param timestamp
     * @param code
     * @return
     */
    public static String signForUpdataConfig(String nonce, String timestamp, String code,String tag) {
        Map<String, String> map = new TreeMap<>();
        map.put("nonce", nonce);
        map.put("timestamp", timestamp);
        map.put("code", code);
        map.put("tag", tag);
        return Md5Utils.createSign(map, SpKey.KEY);
    }
}
